<!--
* @description  : 普通案件/简易案件-立案信息登记
* @descriptionDetail: 普通案件/简易案件-立案信息登记
* @copyright    : 浙江烟草
* @author       : dw
* @create       : 2022-07-10 16:15:38
-->
<template>
  <view class="page case-bg">
    <!-- #ifdef H5-ONLY -->
    <theme-navbar
      :is-white="false"
      :title="navTitle"
      :custom-back="goBack"
      style="z-index: 99999"
    ></theme-navbar>
    <!-- #endif -->
    <view class="main-content">
      <u-form
        class="u-form-m"
        :model="caseData"
        :error-type="['border-bottom', 'message']"
        label-position="top"
        label-width="auto"
        ref="uForm"
      >
        <u-form-item label="案件类型">
          <u-input
            type="text"
            :disabled="true"
            v-model="caseTypeName"
          ></u-input>
        </u-form-item>
        <u-form-item label="承办单位">
          <u-input
            :disabled="true"
            placeholder="请选择"
            v-model="caseData.orgName"
          ></u-input>
        </u-form-item>
        <u-form-item
          label="承办部门"
          prop="regDeptUuid"
          :required="true"
          right-icon="arrow-right"
        >
          <u-input
            :disabled="true"
            placeholder="请选择"
            v-model="caseData.regDeptName"
						:custom-style="valueStyle"
            @click="orgSelectShow = true"
          >
          </u-input>
        </u-form-item>
        <u-form-item
          label="案件时间"
          prop="caseDate"
          :required="true"
          right-icon="arrow-right"
        >
          <u-picker
            mode="time"
            :params="paramsDate"
            v-model="calendar.show"
            @confirm="change"
          >
          </u-picker>
          <u-input
            :disabled="true"
            :needValid="true"
            placeholder="请选择"
						:custom-style="valueStyle"
            v-model="caseData.caseDate"
            @click="showa"
          >
          </u-input>
        </u-form-item>
        <u-form-item
          label="承办人(最少2人)"
          prop="undertakerUuid"
          :required="true"
          right-icon="arrow-right"
        >
          <u-input
            :disabled="true"
            :needValid="true"
            placeholder="请选择"
						:custom-style="valueStyle"
            v-model="caseData.undertaker"
            @click="orgPersonSelectShow = true"
          ></u-input>
        </u-form-item>
        <u-form-item
          label="案由"
          prop="caseOfAction"
          :required="true"
          right-icon="arrow-right"
        >
          <u-input
            :disabled="true"
            :needValid="true"
            placeholder="请选择"
						:custom-style="valueStyle"
            v-model="caseData.caseOfAction"
            @click="choiceCaseOfAction()"
          ></u-input>
        </u-form-item>
        <u-form-item prop="placeGis" :required="true" label="GIS 经纬度">
          <u-input
            placeholder="请选择"
            :needValid="true"
            :disabled="true"
						:custom-style="valueStyle"
            v-model="caseData.placeGis"
          >
          </u-input>
          <u-icon
            name="map-fill"
            :color="$theme.u_type_primary"
            size="44"
            @click="getLocation()"
          ></u-icon>
        </u-form-item>
        <u-form-item label="案发地址" prop="placeStreet" :required="true">
          <view style="display: flex; flex-direction: column; width: 100%">
            <u-input
              type="select"
              :disabled="true"
              placeholder="案发地行政区划选择"
							:custom-style="valueStyle"
              v-model="caseData.casePlaceStr"
              @click=" (nativeNameSelectShow = true)"
            ></u-input>
            <u-line
              :color="$theme.u_border_color"
              style="margin: 10rpx 0"
            ></u-line>
            <u-row gutter="16">
              <u-col span="12">
                <u-input
                  :border="true"
                  :maxlength="50"
                  placeholder="详细地址"
                  v-model="caseData.placeStreet"
                ></u-input>
              </u-col>
            </u-row>
          </view>
        </u-form-item>
        <u-form-item label="集贸市场名称" v-if="caseType != CASE_TYPE.NORMAL">
          <u-input
            placeholder="案发地为集贸市场时填写"
            v-model="caseData.marketName"
          ></u-input>
        </u-form-item>
        <u-form-item label="案件来源" :required="true" prop="caseSourceStr">
          <dic-input
            :keyWord="$u.dic.DIC_KEYS.CASE_SOURCE"
            :dicCode="caseData.caseSource"
            :border="false"
            :type="getCaseSourceCanEdit() ? 'select' : 'text'"
            :select-open="
              dicSelectOpen('caseSource', $u.dic.DIC_KEYS.CASE_SOURCE)
            "
            placeholder="请选择"
            :disabled="true"
						:custom-style="valueStyle"
            v-model="caseData.caseSourceStr"
            @changeInputModelData="
              (name) => {
                $set(caseData, 'caseSourceStr', name);
              }
            "
            @click="
              showDic(
                $u.dic.DIC_KEYS.CASE_SOURCE,
                caseData.caseSource,
                'caseSource'
              )
            "
          />
        </u-form-item>
				<!-- 检查编号 1.2.1 版本并未实现 注释掉 fsx 2023-11-4 start-->
        <u-form-item
          label="检查编号"
          v-if="sourceType"
          right-icon="arrow-right"
        >
          <u-input
            :disabled="true"
            :needValid="true"
            placeholder="请选择"
						:custom-style="valueStyle"
            v-model="caseData.checkActionCodeName"
            @click="getActionCode()"
          ></u-input>
        </u-form-item>
				<!-- 检查编号 1.2.1 版本并未实现 注释掉 fsx 2023-11-4 end -->
        <!-- 来源投诉举报-显示 举报类型 -->
        <u-form-item
          label="举报形式"
          v-if="caseData.caseSource == CASE_SOURCE.reportRecord"
          :required="true"
          prop="reportTypeName"
        >
          <dic-input
            :keyWord="$u.dic.DIC_KEYS.C_REPORT_TYPE"
            :dicCode="caseData.reportType"
            :border="false"
            :type="getCaseSourceCanEdit() ? 'select' : 'text'"
            :select-open="
              dicSelectOpen('reportType', $u.dic.DIC_KEYS.C_REPORT_TYPE)
            "
            placeholder="请选择"
            :disabled="true"
            v-model="caseData.reportTypeName"
            @changeInputModelData="
              (name) => {
                $set(caseData, 'reportTypeName', name);
              }
            "
            @click="
              showDic(
                $u.dic.DIC_KEYS.C_REPORT_TYPE,
                caseData.reportType,
                'reportType'
              )
            "
          />
        </u-form-item>
        <!-- 举报类型 为 举报 需要选择线索编号，投诉 则不需要 -->
        <u-form-item
          label="线索编号"
          v-if="caseData.reportType == REPORT_TYPE.REPORT"
          prop="clueCode"
          :required="true"
          right-icon="arrow-right"
        >
          <u-input
            :disabled="true"
            :needValid="true"
            placeholder="请选择"
						:custom-style="valueStyle"
            v-model="caseData.clueCode"
            @click="choiceClueCode()"
          ></u-input>
        </u-form-item>
        <u-form-item
          label="移送来源"
          v-if="caseData.caseSource == CASE_SOURCE.transIn"
          :required="true"
          prop="transSourceName"
        >
          <dic-input
            :keyWord="$u.dic.DIC_KEYS.C_TRANS_SOURCE"
            :dicCode="caseData.transSource"
            :border="false"
            type="select"
            :select-open="
              dicSelectOpen('transSource', $u.dic.DIC_KEYS.C_TRANS_SOURCE)
            "
            placeholder="请选择"
            :disabled="true"
            v-model="caseData.transSourceName"
            @changeInputModelData="
              (name) => {
                $set(caseData, 'transSourceName', name);
              }
            "
            @click="
              showDic(
                $u.dic.DIC_KEYS.C_TRANS_SOURCE,
                caseData.transSource,
                'transSource'
              )
            "
          />
        </u-form-item>
        <!-- 来源是移送案件 需选择案件编号 -->
        <u-form-item
          label="移交案件编号"
          v-if="caseData.transSource == TRANS_SOURCE.IN_INDUSTRY"
          prop="transCaseCode"
          :required="true"
          right-icon="arrow-right"
        >
          <u-input
            :disabled="true"
            :needValid="true"
            placeholder="请选择"
						:custom-style="valueStyle"
            v-model="caseData.transCaseCode"
            @click="choiceCaseCode()"
          ></u-input>
        </u-form-item>
        <u-form-item label="证据类型" v-if="caseType != CASE_TYPE.SIMPLE">
          <dic-input
            :keyWord="$u.dic.DIC_KEYS.EVID_TYPE"
            :dicCode="caseData.evidTypeCode"
            :border="false"
            type="select"
            :select-open="
              dicMultiSelectOpen('evidTypeCode', $u.dic.DIC_KEYS.EVID_TYPE)
            "
            placeholder="请选择"
            v-model="caseData.evidTypeCodeStr"
            @changeInputModelData="
              (name) => {
                $set(caseData, 'evidTypeCodeStr', name);
              }
            "
            @click="
              showMultiDic($u.dic.DIC_KEYS.EVID_TYPE, caseData.evidTypeCode)
            "
          />
        </u-form-item>
        <u-form-item
          label="查获环节"
          prop="getNodeStr"
          :required="true"
          v-if="caseType != CASE_TYPE.SIMPLE"
        >
          <dic-input
            :keyWord="$u.dic.DIC_KEYS.GET_NODE"
            :dicCode="caseData.getNode"
            :border="false"
            type="select"
            :select-open="
              dicMultiSelectOpen('getNode', $u.dic.DIC_KEYS.GET_NODE)
            "
            placeholder="请选择"
            v-model="caseData.getNodeStr"
            @changeInputModelData="
              (name) => {
                $set(caseData, 'getNodeStr', name);
              }
            "
            @click="showMultiDic($u.dic.DIC_KEYS.GET_NODE, caseData.getNode)"
          />
        </u-form-item>
        <u-form-item
          label="案件来源地"
          v-if="caseType != CASE_TYPE.SIMPLE"
          class="caseFromClass"
        >
          <auto-input
            tplClass="tp-class"
            absIndex="1"
            :searchData="searchData"
            absClass="caseFromClass"
            placeholder="请输入来源地"
            v-model="caseData.caseFrom"
            @choiceAutoItem="choiceAutoItem"
          >
          </auto-input>
        </u-form-item>
        <u-form-item
          label="案件去向地"
          v-if="caseType != CASE_TYPE.SIMPLE"
          class="caseToClass"
        >
          <auto-input
            tplClass="tp-class"
            absIndex="2"
            :searchData="searchData"
            absClass="caseToClass"
            placeholder="请输入去向地"
            v-model="caseData.caseTo"
            @choiceAutoItem="choiceAutoItem"
          >
          </auto-input>
        </u-form-item>
        <u-form-item label="集贸市场名称" v-if="caseType != CASE_TYPE.SIMPLE">
          <u-input
            placeholder="案发地为集贸市场时填写"
            v-model="caseData.marketName"
          ></u-input>
        </u-form-item>
        <u-form-item
          label-width="auto"
          label="是否涉及互联网"
          label-position="left"
          v-if="caseType != CASE_TYPE.SIMPLE"
        >
          <view class="market_cs">
            <u-switch v-model="caseData.isInternetCase"></u-switch>
          </view>
        </u-form-item>
        <u-form-item
          label-width="auto"
          label="是否无主案件"
          label-position="left"
          v-if="caseType != CASE_TYPE.SIMPLE"
        >
          <view class="market_cs">
            <u-switch v-model="caseData.noMaster"></u-switch>
          </view>
        </u-form-item>
        <u-form-item
          label-width="auto"
          prop="isReportHotline"
          required
          label="是否12313转办"
          label-position="left"
        >
          <view class="market_cs">
            <u-switch
              v-model="caseData.isReportHotline"
              @change="hotlineChange"
            ></u-switch>
          </view>
        </u-form-item>
        <u-form-item
          label="受理单号"
          v-if="caseData.isReportHotline"
          :required="caseData.isReportHotline"
          prop="applyCode"
        >
          <u-input
            placeholder="请填写受理单号"
            v-model="caseData.applyCode"
          ></u-input>
        </u-form-item>
        <u-form-item
          label-width="auto"
          required
          label="是否专项行动"
          label-position="left"
        >
          <view class="market_cs">
            <u-switch
              v-model="caseData.isActionResult"
              @change="actionChange"
            ></u-switch>
          </view>
        </u-form-item>
        <u-form-item
          v-if="caseData.isActionResult"
          required
          label="关联专项行动"
          :label-width="220"
          right-icon="arrow-right"
          prop="actionResultName"
        >
          <u-input
            placeholder="请选择关联专项行动"
            :needValid="true"
            :disabled="true"
						:custom-style="valueStyle"
            v-model="caseData.actionResultName"
            @tap="addActionRelation()"
          />
        </u-form-item>
        <u-form-item
          label-width="auto"
          label="是否为运输案件"
          label-position="left"
          v-if="caseType != CASE_TYPE.SIMPLE"
        >
          <view class="market_cs">
            <u-switch
              v-model="caseData.isTransport"
              :disabled="transport"
            ></u-switch>
          </view>
        </u-form-item>
        <u-form-item
          label="运输类型"
          v-if="caseData.isTransport"
          :required="true"
          prop="logisticsTypeStr"
        >
          <dic-input
            :keyWord="$u.dic.DIC_KEYS.C_LOGISTICS_TYPE"
            :dicCode="caseData.logisticsType"
            :border="false"
            type="select"
            :select-open="
              dicSelectOpen('logisticsType', $u.dic.DIC_KEYS.C_LOGISTICS_TYPE)
            "
            placeholder="请选择"
            :disabled="true"
            v-model="caseData.logisticsTypeStr"
            @changeInputModelData="
              (name) => {
                $set(caseData, 'logisticsTypeStr', name);
              }
            "
            @click="
              showDic(
                $u.dic.DIC_KEYS.C_LOGISTICS_TYPE,
                caseData.logisticsType,
                'logisticsType'
              )
            "
          />
        </u-form-item>
        <u-form-item
          label="运输案件案发地"
          v-if="caseData.isTransport"
          :required="true"
          prop="transportAddrStr"
        >
          <dic-input
            :keyWord="$u.dic.DIC_KEYS.C_TRANSPORT_ADDR"
            :dicCode="caseData.transportAddr"
            :border="false"
            type="select"
            :select-open="
              dicSelectOpen('caseSource', $u.dic.DIC_KEYS.C_TRANSPORT_ADDR)
            "
            placeholder="请选择"
            :disabled="true"
            v-model="caseData.transportAddrStr"
            @changeInputModelData="
              (name) => {
                $set(caseData, 'transportAddrStr', name);
              }
            "
            @click="
              showDic(
                $u.dic.DIC_KEYS.C_TRANSPORT_ADDR,
                caseData.transportAddr,
                'caseSource'
              )
            "
          />
        </u-form-item>
        <u-form-item
          label="运输方式"
          v-if="caseData.isTransport"
          :required="true"
          prop="transportStyleStr"
        >
          <dic-input
            :keyWord="$u.dic.DIC_KEYS.C_TRANSPORT_STYLE"
            :dicCode="caseData.transportStyle"
            :border="false"
            type="select"
            :select-open="
              dicMultiSelectOpen(
                'caseSource',
                $u.dic.DIC_KEYS.C_TRANSPORT_STYLE
              )
            "
            placeholder="请选择"
            :disabled="true"
            v-model="caseData.transportStyleStr"
            @changeInputModelData="
              (name) => {
                $set(caseData, 'transportStyleStr', name);
              }
            "
            @click="
              showMultiDic(
                $u.dic.DIC_KEYS.C_TRANSPORT_STYLE,
                caseData.transportStyle
              )
            "
          />
        </u-form-item>
        <u-form-item label="案情摘要" v-if="caseType != CASE_TYPE.SIMPLE">
          <u-input
            placeholder="请输入案情摘要"
            type="textarea"
            v-model="caseData.caseBrief"
          >
          </u-input>
        </u-form-item>
      </u-form>
      <view class="space-content"></view>
    </view>
    <!-- 底部按钮 -->
    <view class="submit-btns btn-other-cls">
      <u-button plain class="u-btn" type="primary" @click="onCancel">
        取消
      </u-button>
      <u-button class="u-btn" type="primary" @click="onConfirm">
        立案
      </u-button>
    </view>
    <!-- 组织机构选择 -->
    <u-popup mode="bottom" height="80%" v-model="orgSelectShow">
      <org-select
        :cleanParentOrg="true"
        :isHybrid="true"
        limitNodeType="all"
        treeType="zm-case"
        @choose="handlerChooseOrg"
      ></org-select>
    </u-popup>
    <!-- 人员选择 -->
    <u-popup mode="bottom" height="80%" v-model="orgPersonSelectShow">
      <org-person-select
        treeType="zm-case"
        @choose="handlerChoosePerson"
      ></org-person-select>
    </u-popup>
    <!-- 行政区选择 -->
    <u-popup mode="bottom" height="80%" v-model="nativeNameSelectShow">
      <area-select @choose="nativeNameSelectShowComfir"></area-select>
    </u-popup>
    <!-- 字典单选 -->
    <dic-choice
      :keyWord="dicKeyWords"
      :currentSelect="dicCurrentSelect"
      v-model="dicShow"
      @confirm="selectDicConfirm"
      :extFilterFun="extFilterFun"
    ></dic-choice>
    <!-- 多选字典组件 -->
    <view>
      <u-popup mode="bottom" height="50%" v-model="mulitChoiceShow">
        <dic-multi-choice
          :keyWord="dicKeyWords"
          :defaultUids="dicCurrentSelect"
          @select="multiChoiceConfirm"
        ></dic-multi-choice>
      </u-popup>
    </view>
  </view>
</template>

<script>
import areaSelect from "@/components/area-select.vue";
import DicChoice from "@/components/dic_choice.vue";
import DicInput from "@/components/dic_input.vue";
import DicMultiChoice from "@/components/dic_multi_choice.vue";
import OrgSelect from "@/components/org-select.vue";
import caseService from "@/service/case/case.service.js";
import commonService from "@/service/common/common.service.js";
import OrgPersonSelect from "@/components/org-person-select.vue";
import zjCommonService from "@/service/common/common.service";
import AutoInput from "@/components/autoInput.vue";
import {
  CASE_SOURCE_REPORT,
  K_SOURCE_TYPE,
} from "@/service/intelligence/mapping/enum.js";
import { v4 as uuidv4 } from "uuid";
import {
  CASE_TYPE,
  CASE_SOURCE,
  REPORT_TYPE,
  TRANS_SOURCE,
} from "@/service/case/mapping/index.js";
export default {
  components: {
    OrgSelect,
    OrgPersonSelect,
    areaSelect,
    DicInput,
    DicChoice,
    DicMultiChoice,
    AutoInput,
  },
  data() {
    return {
      CASE_TYPE,
      CASE_SOURCE,
      REPORT_TYPE,
      TRANS_SOURCE,
      props: undefined,
      from: "", // qb 来源于情报处置
      caseType: CASE_TYPE.NORMAL, // 01 一般案件   02  简易案件
      caseTypeName: CASE_TYPE.NORMAL_CN,
      caseData: {
        employeeList: [],
        retailers: [],
        retailerLicNos: "",
        bcbTypes: {},
        isInternetCase: false,
        party: "",
        regDeptUuid: "",
        regDeptName: "",
        caseDate:"",
        caseOfAction:"",
        casePlaceStr:"",
        placeStreet:"",
        placeProvCode:"",
        placeCityCode:"",
        placeCountyCode:"",
        placeGis:"",
        marketName:"",
        caseSource:"",
        caseSourceStr:"",
        logisticsType:"",
        logisticsTypeStr:"",
        evidTypeCode:"",
        evidTypeCodeStr:"",
        getNode:"",
        getNodeStr:"",
        partLink:"",
        partLinkStr:"",
        toCountyCode:"",
        toCityCode:false,
        isTransport:false,
        noMaster:false,
        isReportHotline:false,
        isActionResult:false,
        transportAddr:"",
        transportAddrStr:"",
        transportStyle:"",
        transportStyleStr:"",
        caseBrief: "",
        actionUuid: "",
        applyCode:'',
				// 添加从市场检查传递的事项id和name fsx 2023-12-8 开始
				checkActionCodeName:"",
				checkActionCode:"" ,
				// 添加从市场检查传递的事项id和name fsx 2023-12-8 end
      },
      dicKeyWords: "",
      dicCurrentSelect:"",
      dicShow: false,
      rightIconStyle: {
        'fontSize': '40rpx',
        'color': this.$theme.u_type_primary,
      },
      nativeNameSelectShow: false,
      orgSelectShow: false,
      orgPersonSelectShow: false,
      user: this.$storage.get(this.$rp.common.USER),
      rules: {
        regDeptUuid: [{
          required: true,
          message: "请选择承办部门",
          trigger: ["change",'blur',],
        },],
        undertakerUuid: [{
          required: true,
          message: "请选择承办人",
          trigger: ["change",'blur',],
        },
        {
          // 自定义验证函数，见上说明
          validator: (rule, value, callback) => {
            return value.split(',').length >= 2;
          },
          message: '承办人最少两个',
          // 触发器可以同时用blur和change
          trigger: ['change', 'blur',],
        },
        ],
        caseDate:[
          {
            required:true,
            message:"请选择案件时间",
            trigger:["change","blur",],
          },
        ],
        caseOfAction:[
          {
            required:true,
            message:"请选择案由",
            trigger: ["change",'blur',],
          },
        ],
        casePlaceStr: [{
          required: true,
          message: '请选择行政区划',
          // 可以单个或者同时写两个触发验证方式
          trigger: ["change",'blur',],
        },],
        placeGis:[{
          required:true,
          message:'经纬度不能为空',
          trigger:['change', 'blur',],
        },],
        caseSourceStr:[{
          required:true,
          message:'请选择案件来源',
          trigger:['change', 'blur',],
        },],
        logisticsTypeStr:[{
          required:true,
          message:'请选择运输类型',
          trigger:['change','blur',],
        },],
        transportAddrStr:[{
          required:true,
          message:'请选择案件案发地',
          trigger:['change','blur',],
        },],
        transportStyleStr:[{
          required:true,
          message:'请选择运输方式',
          trigger:['change','blur',],
        },],
        clueCode:[{
          required:true,
          message:'请选择线索编号',
          trigger:['change','blur',],
        },],
        transCaseCode:[{
          required:true,
          message:'请选择移送案件编号',
          trigger:['change','blur',],
        },],
        actionResultName:[{
          required:true,
          message:'请选择关联专项行动',
          trigger:['change','blur',],
        },],
        applyCode:[{
          required:true,
          message:'请填写受理单号',
          trigger:['change','blur',],
        },],
        getNodeStr:[{
          required:true,
          message:'请选择查获环节',
          trigger:['change','blur',],
        },],
        placeStreet: [{
          required: true,
          message: '请输入详细地址',
          // 可以单个或者同时写两个触发验证方式
          trigger: ['blur',],
        },
        ],
      },
      mulitChoiceShow:false,
      calendar:{
        show:false,
      },
      paramsDate: {
        year: true,
        month: true,
        day: true,
        hour: true,
        minute: true,
        second: true,
        timestamp: true,
      },
      sourceType: false,
      checkUuid: "", // 特殊区域检查、日计划检查
      checkActionCode: "", // 检查处理结果code

      source: null,
			// h5端部分浏览器input设置disabled后点击事件失效 2023-10-25 fsx start
			valueStyle: {
			  marginRight: "5px",
				pointerEvents: "none !important"
			},
			// h5端部分浏览器input设置disabled后点击事件失效 2023-10-25 fsx start

    };
  },
  computed: {
    transportShow(){
      if(this.caseData.isTransport == true){
        return true;
      }else{
        return false;
      }
    },
    transport(){
      if(this.caseData.getNodeStr.indexOf("运输") != -1){
        return true;
      }else{
        return false;
      }
    },
  },
  watch: {
    "caseData.caseSource": {
      handler(val) {
        if (val == "02") {
          this.sourceType = true;
        } else {
          this.sourceType = false;
        }
        // 来源 是投诉举报 默认举报类型是 举报
        if (val == CASE_SOURCE.reportRecord) {
          this.caseData.reportType = REPORT_TYPE.REPORT;
          // 清空 移送案件编号、移送来源
          this.caseData.transSource = "";
          this.caseData.transSourceName = "";
          this.caseData.transCaseCode = "";
          this.caseData.transCaseUuid = "";
        } else if (val == CASE_SOURCE.transIn) {
          this.caseData.transSource = TRANS_SOURCE.IN_INDUSTRY;
          // 清空 线索编号、举报形式
          this.caseData.reportType = "";
          this.caseData.reportTypeName = "";
          this.caseData.clueUuid = "";
          this.caseData.clueCode = "";
        } else {
          this.caseData.reportType = "";
          this.caseData.reportTypeName = "";
          this.caseData.clueUuid = "";
          this.caseData.clueCode = "";
          this.caseData.transSource = "";
          this.caseData.transSourceName = "";
          this.caseData.transCaseCode = "";
          this.caseData.transCaseUuid = "";
        }
      },
    },
  },
  onLoad(opt) {
    //  let param = this.getRouteParam();
    // if (data) {
    //   this.caseData.checkActionCodeName = data.superviseItemName;
    //   this.caseData.jgsxDealUuid = data.jgsxDealUuid;
    // }
    this.caseType = opt.caseType;
    this.checkUuid = opt.checkUuid ? opt.checkUuid : "";
    this.checkActionCode = opt.checkActionCode ? opt.checkActionCode : "";
    this.from = opt.from;
    this.caseData.caseSource = opt.caseSource ? opt.caseSource : "";
    this.caseData.undertaker = opt.undertaker ? opt.undertaker : "";
    this.caseData.undertakerUuid = opt.undertakerUuid ? opt.undertakerUuid : "";
    if (!this.$u.test.isEmpty(opt.applyCode)) {
      this.caseData.applyCode = opt.applyCode;
      this.caseData.isReportHotline = true;
    }
    if (
      this.from == "check" ||
      this.from == "specialAreasCheck" ||
      this.from == "eleCigareCheck"
    ) {
      if (opt.isSpecialAction == "true") {
        this.caseData.isActionResult = true;
        this.caseData.actionResultName = opt.actionName || "";
        this.caseData.actionUuid = opt.actionUuid || "";
      }
			// 获取从市场检查传递的监管事项id和name 并赋值显示 fsx 2023-12-8 开始
			if(opt.jgsxDealUuid) {
				this.caseData.checkActionCodeName = opt.superviseItemName;
				this.caseData.checkActionCode = opt.jgsxDealUuid;
			}
			// 获取从市场检查传递的监管事项id和name 并赋值显示 fsx 2023-12-8 开始
    }

    if(this.caseType == CASE_TYPE.SIMPLE){
      this.caseTypeName = CASE_TYPE.SIMPLE_CN;
    }
    this.props = this.getRouteParam();
    if (!this.props) {
      this.props = {};
    }
  },

  onReady() {
    this.$refs.uForm.setRules(this.rules)
  },
  mounted() {
    this.init();
  },
  methods: {
    init() {
      if (
        !this.$u.test.isEmpty(this.caseData.placeProvCode) &&
        !this.$modal.isMuniCity(this.caseData.placeProvCode)
      ) {
        this.caseData.casePlaceStr =
          commonService.getPersonLocal(this.caseData.placeProvCode, true)
            .areaName || "";
      }
      if (!this.$u.test.isEmpty(this.caseData.placeCityCode)) {
        this.caseData.casePlaceStr +=
          commonService.getPersonLocal(this.caseData.placeCityCode, true)
            .areaName || "";
      }
      if (!this.$u.test.isEmpty(this.caseData.placeCountyCode)) {
        this.caseData.casePlaceStr +=
          commonService.getPersonLocal(this.caseData.placeCountyCode, true)
            .areaName || "";
      }
      if (this.$u.test.isEmpty(this.caseData.placeProvCode)) {
        commonService
          .queryAreaBaseByCode(this.user.user.org.orgUuid)
          .then((res) => {
            if (res.success && res.bean) {
              console.log(res.bean);
              if (this.$modal.isMuniCity(res.bean.procode)) {
                this.caseData.casePlaceStr = [
                  res.bean.admdivname,
                  res.bean.countryname,
                ].join("");
              } else {
                this.caseData.casePlaceStr = [
                  res.bean.proname,
                  res.bean.admdivname,
                  res.bean.countryname,
                ].join("");
              }
              this.caseData.placeProvCode = res.bean.procode;
              this.caseData.placeCityCode = res.bean.admdivcode;
              this.caseData.placeCountyCode = res.bean.countrycode;
            }
          })
          .catch((e) => {
            console.log(e);
          });
      }
      this.caseData.orgName = this.user.docOrgName;
      this.caseData.regDeptName = this.user.deptName;
      this.caseData.regDeptUuid = this.user.deptUuid;
      this.caseData.undertakerUuid = this.caseData.undertakerUuid
        ? this.caseData.undertakerUuid
        : this.user.user.personUuid;
      this.caseData.undertaker = this.caseData.undertaker
        ? this.caseData.undertaker
        : this.user.user.personName;
      this.caseData.employeeList = [
        {
          personName: this.user.user.personName,
          personUuid: this.user.user.personUuid,
          isDef: true,
        },
      ];
      if (this.props.retailerLicNos) {
        this.$modal.showLoading("查询零售户信息中...");
        caseService
          .likeLicNo({
            licNo: this.props.retailerLicNos,
            page: 1,
            limit: 1,
          })
          .then((res) => {
            this.$modal.hideLoading();
            if (!res.success) return;
            let dr = res.data;
            if (dr.length == 0) return;
            this.caseData.retailers = [...dr];
            let retailers = dr[0];
            this.caseData.retailerLicNos = retailers.licNo;
          });
      }
      this.initClue();
    },
    hotlineChange(e) {
      if (!e) {
        this.caseData.applyCode = "";
      }
    },
    // 简易 案件来源过滤处理
    extFilterFun(itm, keyWord) {
      if (
        this.caseType == CASE_TYPE.SIMPLE &&
        keyWord == this.$u.dic.DIC_KEYS.CASE_SOURCE
      ) {
        return (
          itm.bcbCode == CASE_SOURCE.reportRecord ||
          itm.bcbCode == CASE_SOURCE.marketCheck
        );
      }
      return true;
    },
    getCaseSourceCanEdit(){
      if(this.from == 'qb' && this.props.initQueryData.isReport){
        return false;
      }
      return true;
    },
    // 情报立案过来
    initClue() {
      if (this.from != 'qb') return;
      this.caseData.isReport = this.props.initQueryData.isReport;
      this.caseData.clueUuid = this.props.initQueryData.clueUuid;
      this.caseData.clueCode = this.props.initQueryData.clueCode;
      if(this.props.initQueryData.isReport){
        // 举报情况下，案件来源固定为 投诉举报
        this.caseData.caseSource = CASE_SOURCE_REPORT.REPORT;
        this.caseData.caseSourceStr = CASE_SOURCE_REPORT.REPORT_CN;
      }
    },
    choiceCaseOfAction() {
      this.setRouteParam(this.caseData.casePropertyRelList || []);
      this.$u.route({
        url:"/pages/case/components/casePropertySelection",
        params:{
          handleProc: this.caseData.handleProc, // 获取案件类型
        },
      });
    },
    getLocation() {
      this.setRouteParam({disable:false,step:"start",})
      this.$u.route('pages/commonPage/modifyLocationMap');
    },
    handlerChooseOrg(orgs) {
      this.caseData.regDeptUuid = orgs[0].id;
      this.caseData.regDeptName = orgs[0].name;
      this.orgSelectShow = false;
    },
    getActionCode() {
      this.$u.route("pages/case/components/actionCodeList");
    },
    handlerChoosePerson(psrList) {
      let names = [];
      let ids = [];
      psrList.forEach(p => {
        names.push(p.name);
        ids.push(p.id);
      });
      this.caseData.undertakerUuid = ids.join(",");
      this.caseData.undertaker = names.join(",");
      this.orgPersonSelectShow = false;
    },
    searchData(txt) {
      return new Promise((resolve, reject) => {
        commonService
          .queryAreaBaseList(txt)
          .then((res) => {
            if (res.success) {
              let tmp = res.data;
              tmp.forEach((itm) => {
                itm.name = [itm.proname, itm.admdivname, itm.countryname].join(
                  ""
                );
                itm.id = uuidv4();
              });
              console.log("===" + JSON.stringify(tmp));
              resolve(tmp);
            } else {
              resolve([]);
            }
          })
          .catch((err) => {
            resolve([]);
          });
      });
    },
    choiceAutoItem(itm, index) {
      if (index == "1") {
        if (this.$modal.isMuniCity(itm.procode)) {
          this.caseData.caseFrom = [itm.admdivname, itm.countryname].join("");
        } else {
          this.caseData.caseFrom = [
            itm.proname,
            itm.admdivname,
            itm.countryname,
          ].join("");
        }
        this.caseData.fromProvCode = itm.procode;
        this.caseData.fromCityCode = itm.admdivcode;
        this.caseData.fromCountyCode = itm.countrycode;
      } else if (index == "2") {
        if (this.$modal.isMuniCity(itm.procode)) {
          this.caseData.caseTo = [itm.admdivname, itm.countryname].join("");
        } else {
          this.caseData.caseTo = [
            itm.proname,
            itm.admdivname,
            itm.countryname,
          ].join("");
        }
        this.caseData.toProvCode = itm.procode;
        this.caseData.toCityCode = itm.admdivCode;
        this.caseData.toCountyCode = itm.countryCode;
      }
    },
    onConfirm() {
      this.$refs.uForm.validate(valid => {
        if (valid) {
          this.$modal.alert("确认提交吗?", "提示", () => {
            this.$modal.showLoading('请稍后...');
            let param = {};
            if(this.caseType == CASE_TYPE.NORMAL){
              param = this.caseData;
              param.typeCode = "case-simple";
              param.applyCode = this.caseData.applyCode;
              param.isReportHotline = this.caseData.isReportHotline;
            }else if(this.caseType == CASE_TYPE.SIMPLE){
              param = this.caseData;
              param.typeCode = "simpleCase";
              param.applyCode = this.caseData.applyCode;
              param.isReportHotline = this.caseData.isReportHotline;
            }
            // 特殊区域/日计划检查详情-添加简易案件或一般案件
            if(this.checkUuid){
              param.checkUuid = this.checkUuid;
              param.checkActionCode = this.checkActionCode;
            }
            param.casePlace = `${param.casePlaceStr}${param.placeStreet || ''}`;
            console.log(param);
            caseService.saveBasic(param).then(res => {
              this.$modal.hideLoading();
              if(!res.success){
                this.$modal.alert(res.msg);
                return;
              }
              let msg = this.from == 'qb' ? '是否停留在案件页面' : '立案成功';
              if(this.from != 'qb'){
                this.$modal.alert(msg,() => {
                  // TODO 跳转
                  this.setRouteParam({
                    caseCode:res.bean.caseCode,
                    caseUuid:res.bean.caseUuid,
                    handleProc:res.bean.handleProc,
                    from:'host',
                    isDocListPage:false,
                  });
                  this.$u.route({
                    url:'/pages/case/offline/caseInfo',
                    type:"redirect",
                  });
                });
              }else{
                this.$modal.confirm(msg,"提示",() => {
                  // #ifndef H5-DINGDING
                  this.$u.route({
                    url:'/pages/dashboard/dashboard',
                    type:"reLaunch",
                    params:{
                      id:'qb',
                    },
                  });
                  // #endif
                  // #ifdef H5-DINGDING
                  this.$u.route({
                    url:'/pages/case/index',
                    type:"reLaunch",
                  });
                  // #endif
                },() => {
                  this.backPrev({
                    paramKey: "refresh",
                    param: true,
                  },2);
                },'是', '否', '#000000', '#000000')
              }
            }).catch(err => {
              this.$modal.hideLoading();
              this.$modal.alert('提交失败,' + err);
            });
          }, "确定", true);
        }
      });

    },
    getLegalPunishData(arr){
      let punishArgume = [];
      let legalArgume = [];
      for (let i = 0; i < arr.length; i++) {
        if(arr[i].propertySmokeType == '01'){ // 专卖案由
          punishArgume.push(arr[i].punishItem || '');
          legalArgume.push(arr[i].legalItem || '');
        }else{ // 电子烟案由
          let xp = arr[i].smokeIllegalUuid ? arr[i].smokeIllegalUuid.split(",") : [];
          let eilist = arr[i].electricSmokeIllegalList.filter(it => {
            return xp.includes(it.smokeIllegalUuid);
          });
          for (let j = 0; j < eilist.length; j++) {
            punishArgume.push(eilist[j].legalBasic || '');
            legalArgume.push(eilist[j].qualitativeBasic || '');
          }
        }
      }
      this.caseData.punishArgume = punishArgume.join(",");
      this.caseData.legalArgume = legalArgume.join(",");
      console.log(this.caseData);
    },
    updateBackState(param) {
      let transInCase = {};
      let clue_code = '';
      if (param.caseSelectionData) { // 案由选择回调
        let arr = [];
        let arrIds = [];
        param.caseSelectionData.map(itm => {
          itm.caseUuid = this.caseData.caseUuid;
          arr.push(itm.caseProperty);
          arrIds.push(itm.casepropUuid);
        });
        this.isTransCase = arrIds.includes('1') || arrIds.includes('2') || arrIds.includes('3') || arrIds.includes('27');
        this.caseData.casePropertyRelList = param.caseSelectionData;
        this.getLegalPunishData(param.caseSelectionData);
        this.caseData.caseOfAction = arr.join('、');
      } else if (param.pos) { //  定位
        // 回显经纬度
        this.caseData.placeGis = `${param.pos.longitude},${param.pos.latitude}`;
        this.caseData.placeGisX = param.pos.longitude;
        this.caseData.placeGisY = param.pos.latitude;
        let addressName = param.pos.regeocode.addressComponent;
        console.log("===" + JSON.stringify(param.pos));
        let area = commonService.getLocalName(addressName.province,addressName.city,addressName.district);
        let market = param.pos.regeocode.pois[0];
        if(this.$modal.isMuniCity(area.proCode)){
          this.caseData.casePlaceStr = area.admdivName + area.areaName
        }else{
          this.caseData.casePlaceStr = area.proName + area.admdivName + area.areaName
        }
        this.caseData.placeStreet =  addressName.township + addressName.street + addressName.streetNumber
        this.caseData.placeProvCode = area.proCode;
        this.caseData.placeCityCode = area.admdivCode;
        this.caseData.placeCountyCode = area.countryCode;
        this.caseData.marketName = param.pos.regeocode.aois.length != 0 ? param.pos.regeocode.aois[0].name : (param.pos.regeocode.crosses.length != 0 ? (addressName.township + param.pos.regeocode.crosses[0].second_name) : addressName.township)
        this.$forceUpdate();
      }else if(param.report){
        // 线索编号
        // clue_code = param.report[0].clueCode;
        this.caseData.clueCode = param.report[0].clueCode;
        this.caseData.clueUuid = param.report[0].uuid;
        this.$set(this.caseData, "clueCode", this.caseData.clueCode);
        this.$forceUpdate();
      }else if(param.transInCase){
        // 移交案件编号
        transInCase = param.transInCase[0];
        // 回显经纬度
        transInCase.placeGis = `${transInCase.placeGisX},${transInCase.placeGisY}`;
        transInCase.transCaseCode = transInCase.caseCode;
        transInCase.transCaseUuid = transInCase.caseUuid;
        // 案件编号、案件id、案件来源、承办部门、承办单位、承办人不需要赋值
        delete transInCase.caseSource;
        delete transInCase.caseUuid;
        delete transInCase.caseCode;
        delete transInCase.regDeptUuid;
        delete transInCase.regDeptName;
        delete transInCase.orgName;
        delete transInCase.orgUuid;
        delete transInCase.undertaker;
        delete transInCase.undertakerUuid;
        this.caseData = Object.assign(this.caseData, transInCase);
      }else if(param['specialAction']){
        // 选择专项行动
        let actionObj = param['specialAction'][0];
        // 专项行动赋值
        this.caseData.actionUuid = actionObj.actionUuid;
        this.caseData.actionResultName = actionObj.actionName;
        this.$forceUpdate();
      } else if (param.actionCodeList) {
        this.caseData.checkActionCodeName = param.actionCodeList.superviseItemName;
        this.caseData.checkActionCode = param.actionCodeList.jgsxDealUuid;
        this.$forceUpdate()
        console.log( this.caseData,' this.caseData')
      }
    },
    nativeNameSelectShowComfir(areas) {
      if(this.$modal.isMuniCity(areas[0].proCode)){
        this.caseData.casePlaceStr = [areas[0].admdivName, areas[0].countryName,].join("");
      }else{
        this.caseData.casePlaceStr = [areas[0].proName, areas[0].admdivName, areas[0].countryName,].join("");
      }
      this.caseData.placeProvCode = areas[0].proCode;
      this.caseData.placeCityCode = areas[0].admdivCode;
      this.caseData.placeCountyCode = areas[0].countryCode;
      this.nativeNameSelectShow = false;
    },
    selectDicConfirm(e) {
      if (this.dicKeyWords == this.$u.dic.DIC_KEYS.CASE_SOURCE) {
        // 来源类型
        this.caseData.caseSourceStr = e[0].label;
        this.caseData.caseSource = e[0].extra.bcbCode;
      } else if (this.dicKeyWords == this.$u.dic.DIC_KEYS.C_LOGISTICS_TYPE) {
        // 运输类型
        this.caseData.logisticsTypeStr = e[0].label;
        this.caseData.logisticsType = e[0].extra.bcbCode;
      } else if (this.dicKeyWords == this.$u.dic.DIC_KEYS.C_TRANSPORT_ADDR) {
        // 运输类型
        this.caseData.transportAddrStr = e[0].label;
        this.caseData.transportAddr = e[0].extra.bcbCode;
      } else if (this.dicKeyWords == this.$u.dic.DIC_KEYS.C_REPORT_TYPE) {
        // 举报类型
        this.caseData.reportTypeName = e[0].label;
        this.caseData.reportType = e[0].extra.bcbCode;
        // 投诉 清空线索编号
        if (this.caseData.reportType == REPORT_TYPE.COMPLAINTS) {
          this.caseData.clueCode = "";
          this.caseData.clueUuid = "";
        }
      } else if (this.dicKeyWords == this.$u.dic.DIC_KEYS.C_TRANS_SOURCE) {
        // 移送来源
        this.caseData.transSourceName = e[0].label;
        this.caseData.transSource = e[0].extra.bcbCode;
        // 行业外 清空移送案件编号
        if(this.caseData.transSource == TRANS_SOURCE.OUT_INDUSTRY){
          this.caseData.transCaseCode = '';
          this.caseData.transCaseUuid = '';
        }
      }
    },
    dicSelectOpen(type, keyWords) {
      if (type == this.dicType) {
        if (this.dicKeyWords == keyWords && this.dicShow) {
          return true;
        }
        return false;
      }
    },
    showDic(key, cur, type) {
      if (
        (key == this.$u.dic.DIC_KEYS.CASE_SOURCE ||
          key == this.$u.dic.DIC_KEYS.C_REPORT_TYPE) &&
        this.from == "qb"
      ) {
        // 来源于情报
        if (this.props.initQueryData.isReport == true) return;
      }
      if (this.dicShow) return;
      this.dicKeyWords = key;
      this.dicCurrentSelect = cur;
      this.dicShow = true;
      this.dicType = type;
    },
    showMultiDic(key, cur){
      if (this.mulitChoiceShow) return;
      this.dicKeyWords = key;
      this.dicCurrentSelect = cur;
      this.mulitChoiceShow = true;
    },
    dicMultiSelectOpen(type, keyWords){
      if (this.dicKeyWords == keyWords && this.mulitChoiceShow) {
        return true;
      }
      return false;
    },
    multiChoiceConfirm(e) {
      this.mulitChoiceShow = false;
      let labels = [];
      let codes = [];
      e.forEach((itm) => {
        labels.push(itm.bcbName);
        codes.push(itm.bcbCode);
      });
      if (this.dicKeyWords == this.$u.dic.DIC_KEYS.EVID_TYPE) {
        this.caseData.evidTypeCodeStr = labels.join(",");
        this.caseData.evidTypeCode = codes.join(",");
      } else if (this.dicKeyWords == this.$u.dic.DIC_KEYS.GET_NODE) {
        this.caseData.getNodeStr = labels.join(",");
        this.caseData.getNode = codes.join(",");
        if (this.caseData.getNodeStr.indexOf("运输") != -1) {
          this.caseData.isTransport = true;
        }else{
          this.caseData.isTransport = false;
        }
      } else if (this.dicKeyWords == this.$u.dic.DIC_KEYS.C_PART_LINK) {
        this.caseData.partLinkStr = labels.join(",");
        this.caseData.partLink = codes.join(",");
      } else if (this.dicKeyWords == this.$u.dic.DIC_KEYS.C_TRANSPORT_STYLE) {
        // 运输方式
        this.caseData.transportStyleStr = labels.join(",");
        this.caseData.transportStyle = codes.join(",");
      }
    },
    showa(){
      this.calendar.show = true;
    },
    change(e){
      this.caseData.caseDate = this.$u.date(e.timestamp, 'yyyy-mm-dd hh:MM:ss');
    },
    // 取消
    onCancel(){
      uni.navigateBack();
      // this.$u.route('pages/case/index');
      // this.$u.route(-1);
    },
    // 线索列表
    choiceClueCode () {
      if (this.from == 'qb') return;
      this.$u.route('pages/case/components/reportList');
    },
    // 选择移交案件编号
    choiceCaseCode(){
      this.$u.route('pages/case/components/transInCaseList');
    },
    actionChange(val){
      if(!val){
        this.caseData.actionResultName = null;
        this.caseData.actionUuid = null;
      }else{
        if(this.caseData.caseDate){
          // this.querySpecialActionList(); 1.3合并时注释 wumb 方法找不到
        }else{
          this.$u.toast("请选择案发时间!");
          return;
        }
      }
    },
    // 关联专项行动
    addActionRelation() {
      if (this.caseData.caseDate) {
        this.$u.route(
          "/pages/check/specialActionRelationList?caseDate=" +
            this.caseData.caseDate
        );
      } else {
        this.$u.toast("请选择案发时间!");
        return;
      }
    },
  },
};
</script>

<style lang="scss" scoped>
@import "../case_common.scss";
.page {
  padding: 0;
}
/deep/.u-form-item {
  line-height: 28px;
}

.market_cs {
  width: 100%;
  display: flex;
  flex-direction: row;
  justify-content: flex-end;
}
.bottom-btns {
  width: 100%;
  background-color: #ffffff;
  padding: 32rpx;
  height: 150rpx;
  z-index: 10;
  display: flex;
  bottom: 40rpx;
  padding-left: 40rpx;
  padding-right: 40rpx;
  width: 100%;
  text-align: center;
}
.tp-class {
  width: 100%;
}

</style>
